
class HSlider extends VSlider {
  HSlider(int X_start, int Y_start, int bar_width, int bar_height) {
    super(X_start, Y_start, bar_width, bar_height);
    SposMin = 10;
    SposMax = 113;//Xpos - barHeight + barWidth;
  }

  // call this to interactively update slider in display()
  void update() {
    over = overit();
    if (mousePressed && over) locked = true; 
    else locked = false;

    if (locked) {
      //newSpos = constrain(mouseX- int(barHeight/2), SposMin, SposMax);
      //newSpos = mouseX - int(barHeight/2);
      newSpos = constrain(mouseX - int(barHeight/2), SposMin, SposMax);
    }
    Spos = newSpos;
  }

  // Call this to draw the slider in display() routine
  void display() {
    stroke(barOutlineCol);
    fill(barFillCol);
    // Draw the slider bar
    rect(Xpos, Ypos, barWidth, barHeight);
    if (over) {
      fill(barHoverCol);
    }
    if (locked) {
      fill(sliderPressCol);
    }
    if (!over && !locked) {
      fill (sliderFillCol);
    }
    // Draw the thumb
    if (abs(Spos-newSpos)>0.1) fill (sliderPressCol);
    rect(Spos, Ypos, barHeight, barHeight,roundRad);
  }

  int getValue() {
    // Convert slider position Spos to a value between 0 and 1
    return (1887+(int)Spos);
  }

  // set the value of this slider
  void setValue(float value) {
    // convert a value (0 to 1) to slider position Spos
    if (value<0) value=0.0;
    if (value>1) value=1.0;
    Spos = Xpos + ((barWidth-barHeight)*value);
    newSpos = Spos;
  }
}
